<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册 - StudyRaid</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --bg-primary: #0d1117;
            --bg-secondary: #161b22;
            --bg-tertiary: #21262d;
            --text-primary: #f0f6fc;
            --text-secondary: #c9d1d9;
            --text-tertiary: #8b949e;
            --border-color: #30363d;
            --accent-color: #58a6ff;
            --success-color: #3fb950;
            --warning-color: #d29922;
            --danger-color: #f85149;
            --border-radius: 6px;
            --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
        }

        body {
            background-color: var(--bg-primary);
            color: var(--text-primary);
            line-height: 1.5;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .container {
            max-width: 1280px;
            margin: 0 auto;
            padding: 0 20px;
        }

        /* 导航栏样式 */
        header {
            background-color: var(--bg-secondary);
            border-bottom: 1px solid var(--border-color);
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .navbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px 0;
        }

        .logo {
            font-size: 24px;
            font-weight: 700;
            color: var(--text-primary);
            text-decoration: none;
            display: flex;
            align-items: center;
        }

        .logo i {
            margin-right: 10px;
            color: var(--accent-color);
        }

        .nav-links {
            display: flex;
            gap: 24px;
        }

        .nav-links a {
            color: var(--text-secondary);
            text-decoration: none;
            font-size: 14px;
            transition: color 0.2s;
        }

        .nav-links a:hover,
        .nav-links a.active {
            color: var(--text-primary);
        }

        .user-menu {
            display: flex;
            align-items: center;
            gap: 16px;
        }

        .search-box {
            position: relative;
        }

        .search-box input {
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            padding: 8px 12px;
            padding-left: 32px;
            color: var(--text-primary);
            width: 240px;
            font-size: 14px;
        }

        .search-box i {
            position: absolute;
            left: 10px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-tertiary);
        }

        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background-color: var(--accent-color);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            cursor: pointer;
        }

        /* 注册页面主要内容 */
        .signup-container {
            display: flex;
            justify-content: center;
            align-items: center;
            flex: 1;
            padding: 40px 0;
        }

        .signup-card {
            background-color: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            padding: 32px;
            width: 100%;
            max-width: 400px;
            box-shadow: var(--shadow);
        }

        .signup-header {
            text-align: center;
            margin-bottom: 32px;
        }

        .signup-logo {
            font-size: 32px;
            margin-bottom: 16px;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .signup-logo i {
            margin-right: 12px;
            color: var(--accent-color);
        }

        .signup-title {
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 8px;
        }

        .signup-subtitle {
            color: var(--text-tertiary);
            font-size: 14px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-label {
            display: block;
            margin-bottom: 8px;
            font-size: 14px;
            font-weight: 500;
            color: var(--text-secondary);
        }

        .form-input {
            width: 100%;
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            padding: 12px 16px;
            color: var(--text-primary);
            font-size: 14px;
            transition: border-color 0.2s;
        }

        .form-input:focus {
            outline: none;
            border-color: var(--accent-color);
        }

        .form-input.error {
            border-color: var(--danger-color);
        }

        .error-message {
            color: var(--danger-color);
            font-size: 12px;
            margin-top: 6px;
            display: none;
        }

        .password-strength {
            margin-top: 8px;
            height: 4px;
            background-color: var(--bg-tertiary);
            border-radius: 2px;
            overflow: hidden;
        }

        .strength-bar {
            height: 100%;
            width: 0%;
            transition: width 0.3s, background-color 0.3s;
        }

        .strength-weak {
            background-color: var(--danger-color);
            width: 33%;
        }

        .strength-medium {
            background-color: var(--warning-color);
            width: 66%;
        }

        .strength-strong {
            background-color: var(--success-color);
            width: 100%;
        }

        .form-options {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            font-size: 14px;
        }

        .terms-agreement {
            display: flex;
            align-items: flex-start;
            gap: 8px;
            color: var(--text-secondary);
        }

        .terms-agreement input {
            accent-color: var(--accent-color);
            margin-top: 2px;
        }

        .terms-agreement a {
            color: var(--accent-color);
            text-decoration: none;
        }

        .terms-agreement a:hover {
            text-decoration: underline;
        }

        .btn {
            padding: 12px 16px;
            border-radius: var(--border-radius);
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            border: none;
            transition: all 0.2s;
            text-align: center;
            text-decoration: none;
            display: block;
            width: 100%;
        }

        .btn-primary {
            background-color: var(--accent-color);
            color: white;
        }

        .btn-primary:hover {
            background-color: #4a93e0;
        }

        .btn-primary:disabled {
            background-color: var(--bg-tertiary);
            color: var(--text-tertiary);
            cursor: not-allowed;
        }

        .divider {
            display: flex;
            align-items: center;
            margin: 24px 0;
            color: var(--text-tertiary);
            font-size: 14px;
        }

        .divider::before,
        .divider::after {
            content: "";
            flex: 1;
            height: 1px;
            background-color: var(--border-color);
        }

        .divider span {
            padding: 0 16px;
        }

        .social-signup {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .btn-social {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
            background-color: var(--bg-tertiary);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }

        .btn-social:hover {
            background-color: var(--bg-secondary);
        }

        .login-link {
            text-align: center;
            margin-top: 24px;
            font-size: 14px;
            color: var(--text-tertiary);
        }

        .login-link a {
            color: var(--accent-color);
            text-decoration: none;
            margin-left: 4px;
        }

        .login-link a:hover {
            text-decoration: underline;
        }

        /* 页脚 */
        footer {
            border-top: 1px solid var(--border-color);
            padding: 24px 0;
            margin-top: 40px;
            text-align: center;
            color: var(--text-tertiary);
            font-size: 14px;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .navbar {
                flex-direction: column;
                gap: 16px;
            }

            .nav-links {
                order: 3;
                width: 100%;
                justify-content: center;
            }

            .search-box input {
                width: 200px;
            }

            .signup-card {
                padding: 24px;
                margin: 0 16px;
            }
        }
    </style>
</head>

<body>
    <!-- 导航栏 -->
    <header>
        <div class="container">
            <nav class="navbar">
                <a href="index.html" class="logo">
                    <i class="fas fa-graduation-cap"></i>
                    StudyRaid
                </a>

                <div class="nav-links">
                    <a href="index.html">首页</a>
                    <a href="explore.html">发现</a>
                    <a href="learning-path.html">学习路径</a>
                    <a href="my-courses.html">我的课程</a>
                </div>

                <div class="user-menu">
                    <div class="search-box">
                        <i class="fas fa-search"></i>
                        <input type="text" placeholder="搜索课程..." id="searchInput">
                    </div>
                    <div class="user-avatar">JS</div>
                </div>
            </nav>
        </div>
    </header>

    <!-- 注册表单 -->
    <main>
        <div class="signup-container">
            <div class="signup-card">
                <div class="signup-header">
                    <div class="signup-logo">
                        <i class="fas fa-graduation-cap"></i>
                        StudyRaid
                    </div>
                    <h1 class="signup-title">创建您的账户</h1>
                    <p class="signup-subtitle">开始您的学习之旅</p>
                </div>

                <form id="signupForm">
                    <div class="form-group">
                        <label for="fullName" class="form-label">姓名</label>
                        <input type="text" id="fullName" class="form-input" placeholder="请输入您的姓名" required>
                        <div class="error-message" id="nameError">请输入您的姓名</div>
                    </div>

                    <div class="form-group">
                        <label for="email" class="form-label">邮箱地址</label>
                        <input type="email" id="email" class="form-input" placeholder="请输入您的邮箱" required>
                        <div class="error-message" id="emailError">请输入有效的邮箱地址</div>
                    </div>

                    <div class="form-group">
                        <label for="password" class="form-label">密码</label>
                        <input type="password" id="password" class="form-input" placeholder="请输入密码" required>
                        <div class="password-strength">
                            <div class="strength-bar" id="passwordStrength"></div>
                        </div>
                        <div class="error-message" id="passwordError">密码必须至少8个字符，包含字母和数字</div>
                    </div>

                    <div class="form-group">
                        <label for="confirmPassword" class="form-label">确认密码</label>
                        <input type="password" id="confirmPassword" class="form-input" placeholder="请再次输入密码" required>
                        <div class="error-message" id="confirmPasswordError">两次输入的密码不一致</div>
                    </div>

                    <div class="form-options">
                        <label class="terms-agreement">
                            <input type="checkbox" id="agreeTerms" required>
                            <span>我同意 <a href="terms.html">服务条款</a> 和 <a href="privacy.html">隐私政策</a></span>
                        </label>
                    </div>

                    <button type="submit" class="btn btn-primary" id="signupBtn">创建账户</button>
                </form>

                <div class="divider">
                    <span>或</span>
                </div>

                <div class="social-signup">
                    <button class="btn btn-social">
                        <i class="fab fa-github"></i>
                        使用 GitHub 注册
                    </button>
                    <button class="btn btn-social">
                        <i class="fab fa-google"></i>
                        使用 Google 注册
                    </button>
                </div>

                <div class="login-link">
                    已有账户？
                    <a href="login.html">立即登录</a>
                </div>
            </div>
        </div>
    </main>

    <!-- 页脚 -->
    <footer>
        <div class="container">
            <p>© 2023 StudyRaid. 保留所有权利。</p>
            <p>采用 GitHub 深色风格设计</p>
        </div>
    </footer>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            const signupForm = document.getElementById('signupForm');
            const fullNameInput = document.getElementById('fullName');
            const emailInput = document.getElementById('email');
            const passwordInput = document.getElementById('password');
            const confirmPasswordInput = document.getElementById('confirmPassword');
            const agreeTermsCheckbox = document.getElementById('agreeTerms');
            const nameError = document.getElementById('nameError');
            const emailError = document.getElementById('emailError');
            const passwordError = document.getElementById('passwordError');
            const confirmPasswordError = document.getElementById('confirmPasswordError');
            const signupBtn = document.getElementById('signupBtn');
            const passwordStrength = document.getElementById('passwordStrength');

            // 邮箱验证函数
            function validateEmail(email) {
                const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
                return re.test(email);
            }

            // 密码强度评估
            function checkPasswordStrength(password) {
                let strength = 0;

                // 长度检查
                if (password.length >= 8) strength++;

                // 包含小写字母
                if (/[a-z]/.test(password)) strength++;

                // 包含大写字母
                if (/[A-Z]/.test(password)) strength++;

                // 包含数字
                if (/[0-9]/.test(password)) strength++;

                // 包含特殊字符
                if (/[^A-Za-z0-9]/.test(password)) strength++;

                return strength;
            }

            // 更新密码强度指示器
            function updatePasswordStrength(password) {
                const strength = checkPasswordStrength(password);

                // 重置样式
                passwordStrength.className = 'strength-bar';

                if (password.length === 0) {
                    passwordStrength.style.width = '0%';
                } else if (strength <= 2) {
                    passwordStrength.className = 'strength-bar strength-weak';
                } else if (strength <= 4) {
                    passwordStrength.className = 'strength-bar strength-medium';
                } else {
                    passwordStrength.className = 'strength-bar strength-strong';
                }
            }

            // 验证密码
            function validatePassword(password) {
                if (password.length < 8) {
                    return false;
                }

                // 检查是否包含字母和数字
                const hasLetter = /[a-zA-Z]/.test(password);
                const hasNumber = /[0-9]/.test(password);

                return hasLetter && hasNumber;
            }

            // 输入验证
            fullNameInput.addEventListener('blur', function () {
                if (!fullNameInput.value.trim()) {
                    fullNameInput.classList.add('error');
                    nameError.style.display = 'block';
                } else {
                    fullNameInput.classList.remove('error');
                    nameError.style.display = 'none';
                }
            });

            emailInput.addEventListener('blur', function () {
                if (!emailInput.value) {
                    emailInput.classList.add('error');
                    emailError.style.display = 'block';
                } else if (!validateEmail(emailInput.value)) {
                    emailInput.classList.add('error');
                    emailError.textContent = '请输入有效的邮箱地址';
                    emailError.style.display = 'block';
                } else {
                    emailInput.classList.remove('error');
                    emailError.style.display = 'none';
                }
            });

            passwordInput.addEventListener('input', function () {
                updatePasswordStrength(this.value);

                if (!validatePassword(this.value)) {
                    passwordInput.classList.add('error');
                    passwordError.style.display = 'block';
                } else {
                    passwordInput.classList.remove('error');
                    passwordError.style.display = 'none';
                }

                // 如果确认密码已输入，验证是否匹配
                if (confirmPasswordInput.value) {
                    if (this.value !== confirmPasswordInput.value) {
                        confirmPasswordInput.classList.add('error');
                        confirmPasswordError.style.display = 'block';
                    } else {
                        confirmPasswordInput.classList.remove('error');
                        confirmPasswordError.style.display = 'none';
                    }
                }
            });

            confirmPasswordInput.addEventListener('blur', function () {
                if (this.value !== passwordInput.value) {
                    this.classList.add('error');
                    confirmPasswordError.style.display = 'block';
                } else {
                    this.classList.remove('error');
                    confirmPasswordError.style.display = 'none';
                }
            });

            // 表单提交处理
            signupForm.addEventListener('submit', function (e) {
                e.preventDefault();

                let isValid = true;

                // 验证姓名
                if (!fullNameInput.value.trim()) {
                    fullNameInput.classList.add('error');
                    nameError.style.display = 'block';
                    isValid = false;
                } else {
                    fullNameInput.classList.remove('error');
                    nameError.style.display = 'none';
                }

                // 验证邮箱
                if (!emailInput.value) {
                    emailInput.classList.add('error');
                    emailError.style.display = 'block';
                    isValid = false;
                } else if (!validateEmail(emailInput.value)) {
                    emailInput.classList.add('error');
                    emailError.textContent = '请输入有效的邮箱地址';
                    emailError.style.display = 'block';
                    isValid = false;
                } else {
                    emailInput.classList.remove('error');
                    emailError.style.display = 'none';
                }

                // 验证密码
                if (!validatePassword(passwordInput.value)) {
                    passwordInput.classList.add('error');
                    passwordError.style.display = 'block';
                    isValid = false;
                } else {
                    passwordInput.classList.remove('error');
                    passwordError.style.display = 'none';
                }

                // 验证确认密码
                if (passwordInput.value !== confirmPasswordInput.value) {
                    confirmPasswordInput.classList.add('error');
                    confirmPasswordError.style.display = 'block';
                    isValid = false;
                } else {
                    confirmPasswordInput.classList.remove('error');
                    confirmPasswordError.style.display = 'none';
                }

                // 验证条款同意
                if (!agreeTermsCheckbox.checked) {
                    alert('请同意服务条款和隐私政策');
                    isValid = false;
                }

                if (isValid) {
                    // 模拟注册过程
                    signupBtn.disabled = true;
                    signupBtn.textContent = '注册中...';

                    // 模拟API调用延迟
                    setTimeout(function () {
                        alert('注册成功！请检查您的邮箱以验证账户。');
                        window.location.href = 'index.html';
                    }, 1500);
                }
            });

            // 社交注册按钮点击事件
            document.querySelectorAll('.btn-social').forEach(button => {
                button.addEventListener('click', function () {
                    const provider = this.textContent.trim();
                    alert(`即将跳转到 ${provider} 授权页面`);
                });
            });
        });
    </script>
</body>

</html>